import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/pages/my_webview/my_webview_page.dart';
import 'package:yysk_app/routes/global_controller.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/js_tool.dart';

class LisenceWidget extends StatelessWidget {
  final double? fontSize;
  final Color? color;
  const LisenceWidget({
    super.key,
    this.fontSize = 12,
    this.color = AppColors.fontColorBlack,
  });

  @override
  Widget build(BuildContext context) {
    final GlobalController globalController = Get.find();
    final staticInfo = globalController.staticInfo.value;
    return Row(
      children: [
        Text('我已阅读并同意', style: TextStyle(fontSize: fontSize, color: color)),
        InkWell(
          onTap: () async {
            Get.toNamed(
              '${MyWebViewPage.path}?url=${Uri.encodeComponent(staticInfo?.userAgreement ?? rulePages.userRule)}',
              arguments: {
                'url': Uri.encodeComponent(
                  staticInfo?.userAgreement ?? rulePages.userRule,
                ),
              },
            );
          },
          child: Text(
            '《用户协议》',
            style: TextStyle(
              color: AppColors.backgroundColorGreenLight,
              fontSize: fontSize,
            ),
          ),
        ),
        InkWell(
          onTap: () async {
            Get.toNamed(
              '${MyWebViewPage.path}?url=${Uri.encodeComponent(staticInfo?.privacyPolicy ?? rulePages.privacyAgreement)}',
              arguments: {
                'url': Uri.encodeComponent(
                  staticInfo?.privacyPolicy ?? rulePages.privacyAgreement,
                ),
              },
            );
          },
          child: Text(
            '《隐私协议》',
            style: TextStyle(
              color: AppColors.backgroundColorGreenLight,
              fontSize: fontSize,
            ),
          ),
        ),
      ],
    );
  }
}
